package OOP.SmallCash;
import java.text.SimpleDateFormat;
import java.util.*;
public class Pocket {
    private double money;

    //获取日期
    Date date = new Date();
    SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
    public Pocket(double money) {
        this.money = money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public double getMoney() {
        return money;
    }

    //存钱并计入记账本
    public void inmoney(Recoder rec,double money){
        this.money += money;
        System.out.println("存入成功！ 原本资金："+ (this.money-money)+ "  存入后： "+this.money);
        rec.recoder("收益入账","+"+money,dateFormat.format(date),"余额："+this.money);
    }
    //取钱并计入记账本
    public void outmoney(Recoder rec,String place,double money){
        if(money<0 || money > this.money){
            System.out.println("您的资金不够消费或金额小于零  您的资金为： "+ this.money);
        }
        else{
            this.money -= money;
            System.out.println("消费完成！ 原本资金："+ (this.money + money)+"  消费后： "+this.money);
            rec.recoder(place,"-"+money,dateFormat.format(date),"余额："+this.money);
        }
    }
}
